-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgraded library to support most features of WM8960 I2C protocol #2
Conversation
…M8960_Arduino_Library for use with CircuitPython.
…the original library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It seems like this was autoconverted from the Arduino library. That's fine except you now need to curate and refine the API for Python.
Generally we don't want to expose everything. Instead, we only want the APIs we need for the examples we want to show. Your extended examples are a great place to start for this.
I've pointed out a couple things and linked to the dev guide. Please read the dev guide over and refine the API to match that.
Thanks!
Hey Scott! Thanks for looking over this library. I think all of your suggestions so far are on the right track and I will be following your updates shortly. The only note I'll make is that I did manually convert this library (with extensive use of find and replace, of course), which is why there might be some mistakes here and there. Though I think there is some benefit to maintaining a some compatibility with the original library, I also think it's a great idea to implement the CircuitPython methodology where possible. However, if a tool does exist to automatically convert Arduino libraries to be compatible with CircuitPython, that would be really great! |
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
An LLM like ChatGPT or GitHub Copilot can do this conversion pretty well. Give it the source arduino and ask it to generate python. It may even be able to convert to properties. You'll still need to check and refine it but it makes the initial conversion much quicker. |
I've gotten around to revisiting the examples provided and narrowed them down to only 4 which I felt demonstrated unique features. If I2SInOut ever reaches the light in CircuitPython, I'll make sure to add an example which features ADC to MCU functionality. https://adafruit-circuitpython-wm8960.readthedocs.io/projects/dev/en/latest/examples.html |
…nd `missing-class-docstring`).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples look really good. I like how readable the human friendly names are.
One comment about formatting and it looks like you are still working on adding doc strings.
…it_wm8960.WM8960`, and advanced driver class, `adafruit_wm8960.advanced.WM8960_Advanced`. Documentation completed.
@tannewt Here's the updated library. All the documentation has been populated as far as I'm aware. It may get a bit lackadaisical here and there, but I'll leave it up to your scrutiny. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like pre-commit is unhappy. One missing space. Otherwise the comments look really good! This will be a very helpful driver for folks using this chip. Thanks!
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
I think you need to change this to fix the build issue: Adafruit_CircuitPython_WM8960/pyproject.toml Lines 41 to 44 in cf3620d
|
I think that finally does it! Let me know if there's anything else I need to check up on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good! Thanks for iterating on this with me.
@tannewt Likewise! I'm excited to start using this in my next project. |
awesome, thank you @dcooperdalrymple :) |
I was eager to use SparkFun's WM8960 breakout board with a CircuitPython project, and found this unfinished library to provide a starting point to communicate with this device but otherwise lacking.
To ameliorate this problem, I've ported over the Arduino library and examples provided by SparkFun for this board (https://github.com/sparkfun/SparkFun_WM8960_Arduino_Library) with a few minor modifications:
setSampleRate
to automatically configure PLL, system clock, etc for most supported frequencies (8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000)configureI2S
,configureDAC
,configureHeadphones
,configureSpeakers
setPPLK
uses a single integer value rather than 3 separate bytesAll examples have been tested with an RP2040 and WM8960 breakout module successfully. That is except for those involving I2S input (examples 08, 09, 11, and 15) because I2SIn/I2SInOut is not yet a feature of CircuitPython (as of 9.1.1; more info: adafruit/circuitpython#2676).
I look forward to seeing this library added to the community bundle after review (https://github.com/adafruit/CircuitPython_Community_Bundle) as I think this is a very powerful codec with a large feature set for the price and is already being used in 1 Adafruit product, https://www.adafruit.com/product/4757.
I did my best to give attribution to Pete Lewis of SparkFun, the original author of the Arduino library, under the MIT license, but there may be room for improvement.
Thank you for your consideration!